package com.weiyi.mashangzhu.Roomer.Adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.weiyi.mashangzhu.API.API;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Activity.HouseDetailsActivity;
import com.weiyi.mashangzhu.Roomer.Bean.FriendBean;
import com.weiyi.mashangzhu.Utils.GlideImgManager;

import java.util.List;

/**
 * Created by win7 on 2017/5/12.
 */

public class FriendAdapter extends BaseAdapter {
    List<FriendBean.DataBean> list;
    Context context;

    public FriendAdapter(List<FriendBean.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_friend, null);
            viewHolder.count = (TextView) convertView.findViewById(R.id.count);
            viewHolder.name = (TextView) convertView.findViewById(R.id.name);
            viewHolder.head = (ImageView) convertView.findViewById(R.id.head);
            convertView.setTag(viewHolder);

        }
        viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.count.setText("+"+list.get(position).getReward()+"");
        viewHolder.name.setText(list.get(position).getUNickname()+"");
        GlideImgManager.glideLoader(context, API.BaseApi_url+list.get(position).getUHead(),R.mipmap.errer,viewHolder.head,0);
        return convertView;
    }

    class ViewHolder {
        TextView count,name;
        ImageView head;
    }
}
